package com.ruoyi.project.naming.kangxistat.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.naming.kangxistat.domain.KangxiStat;
import com.ruoyi.project.naming.kangxistat.service.IKangxiStatService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 康熙统计Controller
 * 
 * @author shixiangwen
 * @date 2025-02-13
 */
@Controller
@RequestMapping("/naming/kangxistat")
public class KangxiStatController extends BaseController
{
    private String prefix = "naming/kangxistat";

    @Autowired
    private IKangxiStatService kangxiStatService;

    @RequiresPermissions("naming:kangxistat:view")
    @GetMapping()
    public String kangxistat()
    {
        return prefix + "/kangxistat";
    }

    /**
     * 查询康熙统计列表
     */
    @RequiresPermissions("naming:kangxistat:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(KangxiStat kangxiStat)
    {
        startPage();
        List<KangxiStat> list = kangxiStatService.selectKangxiStatList(kangxiStat);
        return getDataTable(list);
    }

    /**
     * 导出康熙统计列表
     */
    @RequiresPermissions("naming:kangxistat:export")
    @Log(title = "康熙统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(KangxiStat kangxiStat)
    {
        List<KangxiStat> list = kangxiStatService.selectKangxiStatList(kangxiStat);
        ExcelUtil<KangxiStat> util = new ExcelUtil<KangxiStat>(KangxiStat.class);
        return util.exportExcel(list, "康熙统计数据");
    }

    /**
     * 新增康熙统计
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存康熙统计
     */
    @RequiresPermissions("naming:kangxistat:add")
    @Log(title = "康熙统计", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(KangxiStat kangxiStat)
    {
        return toAjax(kangxiStatService.insertKangxiStat(kangxiStat));
    }

    /**
     * 修改康熙统计
     */
    @RequiresPermissions("naming:kangxistat:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        KangxiStat kangxiStat = kangxiStatService.selectKangxiStatById(id);
        mmap.put("kangxiStat", kangxiStat);
        return prefix + "/edit";
    }

    /**
     * 修改保存康熙统计
     */
    @RequiresPermissions("naming:kangxistat:edit")
    @Log(title = "康熙统计", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(KangxiStat kangxiStat)
    {
        return toAjax(kangxiStatService.updateKangxiStat(kangxiStat));
    }

    /**
     * 删除康熙统计
     */
    @RequiresPermissions("naming:kangxistat:remove")
    @Log(title = "康熙统计", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(kangxiStatService.deleteKangxiStatByIds(ids));
    }
}
